﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Enterprise.Model.Manager;
using Enterprise.Data.Manager;
using Enterprise.Infrastructure;
namespace Enterprise.Service.Manager
{
    /// <summary>
    ///  经理信箱回复服务
    /// </summary>
    public class MsgReplyService
    {
        /// <summary>
        /// 经理信箱列表 返回留言的所有回复
        /// </summary>
        /// <param name="msgId">留言编号</param>
        /// <returns></returns>
        public List<MsgReplyEntity> MsgReplyList(int msgId)
        {
            MsgReplyData data = new MsgReplyData();
            List<MsgReplyEntity> list = data.MsgReplyList(msgId);
            return list;
        }

        /// <summary>
        /// 经理信箱回复留言操作 添加、修改、删除
        /// </summary>
        /// <param name="entity">经理信箱回复实体</param>
        public void MsgReplyExecute(MsgReplyEntity entity)
        {
            string cmd = string.Empty;
            switch (entity.DB_Option_Action)
            {
                case "Insert":
                    cmd = "Insert into MANAGER_MSGREPLY(REPLYID,MSGID,REPLYCONTENT,REPLYISSHOW,REPLYIP,REPLYTIME) values(SEQ_MANAGER_MSGREPLY.nextval," + entity.MsgId + ",'" + entity.ReplyContent + "'," + entity.ReplyIsShow + ",'" + entity.ReplyIp + "'," + Utility.FormatOracleDate(entity.ReplyTime) + ")";
                    break;
                case "Update":
                    cmd = "Update MANAGER_MSGREPLY set REPLYCONTENT='" + entity.ReplyContent + "' , REPLYISSHOW=" + entity.ReplyIsShow + " , REPLYIP='" + entity.ReplyIp + "' , REPLYTIME='" + entity.ReplyTime + "' where REPLYID=" + entity.ReplyId;
                    break;
                case "Delete":
                    cmd = "Delete from MANAGER_MSGREPLY where REPLYID=" + entity.ReplyId;
                    break;
            }
            if (!string.IsNullOrEmpty(cmd))
            {
                MsgReplyExecuteBySql(cmd);
            }
        }

        /// <summary>
        /// 经理信箱回复操作  
        /// </summary>
        /// <param name="cmd">sql语句</param>
        public void MsgReplyExecuteBySql(string cmd)
        {
            MsgReplyData data = new MsgReplyData();
            data.MsgReplyExecute(cmd);
        }

    }
}
